package com.sunop.userservice.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.sunop.panticommon.entity.Result;
import com.sunop.userservice.model.User;
import com.sunop.userservice.model.UserBaseDTO;
import com.sunop.userservice.model.UserRegisterDto;
import com.sunop.userservice.model.UserUpdateInfo;
import org.springframework.mail.MailException;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * @since 2025-03-12
 */
public interface UserService extends IService<User> {

    Result register(UserRegisterDto userRegisterDto);

    Integer selectByNameAndPassword(String username, String password);

    Result uploadFile(MultipartFile file);

    InputStream downloadFile(String path);

    String getFilePath();

    void storeVerificationCode(String email, String code);

    boolean verifyVerificationCode(String email, String code);

    void deleteVerificationCode(String email);

    // 频率限制实现
    boolean isEmailRateLimited(String email);

    // 邮件发送实现
    @Retryable(value = {MailException.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000))
    void sendVerificationEmail(String toEmail, String verificationCode);

    Result sendVerificationCode(String email);

    String generateVerificationCode();

    Result updateInfo(UserUpdateInfo userInfo);

    UserBaseDTO getUserBaseDTO(Integer userId);

    int getclassId(int userId);

    List<Integer> getUserOverProblemIds(int userId);
}
